package com.zc.study.java编程思想.第二章一切都是对象;

import sun.applet.Main;

import java.util.*;
import java.util.concurrent.locks.Condition;

public class 截尾和舍入 {
    public static void main(String[] args) {
        //数字转型进行截尾操作
     double a = 0.7,b=0.4;
     float c = 0.7f,d=0.4f;
        System.out.println((int)a);
        System.out.println((int)b);
        System.out.println((int)c);
        System.out.println((int)d);
        //想要四舍五人
        System.out.println(Math.round(a));
        System.out.println(Math.round(b));
        System.out.println(Math.round(c));
        System.out.println(Math.round(d));

        char aa = 1;
        int bb = 2;
        int cc = aa+bb;
        System.out.println(cc);

        while(Condition()){
            System.out.println("true");
        }

        for(char z = 0;z<128;z++){
            if(Character.isLowerCase(z)){
                System.out.println("value"+(int)z+"character:"+z);
            }
        }

        //流程控制for
        getMap(25);
        //test return continue break;
        testGoTu();
    }

    private static void testGoTu() {
        int i = 0,j=0;
        for(;;){
            if(i%2 == 0){
                i=++i;
                continue;
            }
            System.out.println("i::"+i);
            while (true){
                /*if(j>5){
                    return;
                }*/
                if(j>11){
                    j=0;
                    break;
                }
                System.out.println("j::"+j);
                j+=1;
            }
            i=++i;
            if(i>10){
                break;
            }
        }
    }

    public static boolean Condition(){
        return Math.random()<0.99;
    }



    public static  void  getMap(int number){
        List<Integer> list = new ArrayList<>(number);
        Random rand = new Random();
        for(int i = 1;i<=number;i++){
            list.add(rand.nextInt(100));
        }
        Map<String,Map<Integer,String>> map = new HashMap<>();
        Map<Integer,String> bigMap = new HashMap<>();
        Map<Integer,String> equalMap = new HashMap<>();
        Map<Integer,String> SmallMap = new HashMap<>();

        map.put("大",bigMap);
        map.put("等",equalMap);
        map.put("小",SmallMap);
        for(int i = 0;i<number-1;i++){
            int a = list.get(i);
            int b = list.get(i+1);
            if(a>b){
                bigMap.put(i+1,a+",下一个数是"+b);
            }else if( a == b){
                equalMap.put(i+1,a+",下一个数是"+b);
            }else{
                SmallMap.put(i+1,a+",下一个数是"+b);
            }
        }
        map.forEach((k,v)->{
            System.out.println(k);
            v.forEach((j,z)->{
                System.out.println("index:"+j+"  value:"+z);
            });
        });
    }

}
